package StudyCode.summary.myfile;

import java.io.File;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class SaveFileByCreateParentFile {
	public static void main(String[] args) {
		saveFile("E:\\Copy", "1.txt");
	}

	private static void saveFile(String destFilePathStr, String destFileName) {
		try {
			File destFilePath = new File(destFilePathStr);
			if (!destFilePath.exists()) {
				destFilePath.mkdirs();
				System.out.println(destFilePathStr + " 不存在，已创建.");
			}
			File destFile = new File(destFilePathStr + "//" + destFileName);
			if (!destFile.exists()) {
				destFile.createNewFile();
				System.out.println(destFile.getPath() + " 保存成功。");
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
